<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      .tab_list {
        overflow: hidden;
      }
      .red {
        background-color: #c81623;
        color: #ffffff;
      }
      .tab_list ul li {
        float: left;
        list-style: none;
        height: 39px;
        line-height: 39px;
        padding: 0 20px;
        text-align: center;
        cursor: pointer;
      }
      .tab_con div {
        display: none;
      }
    </style>
  </head>
  <body>
    <div class="tab">
      <div class="tab_list">
        <ul>
          <li class="red">商品介绍</li>
          <li>规格与包装</li>
          <li>售后保障</li>
          <li>商品评价(5000)</li>
          <li>手机社区</li>
        </ul>
      </div>
      <div class="tab_con">
        <div style="display: block">商品介绍模块</div>
        <div>规格与包装模块</div>
        <div>售后保障模块</div>
        <div>商品评价模块</div>
        <div>手机社区</div>
      </div>
    </div>
    <script>
      var lis = document.querySelectorAll('.tab_list li');
      var div = document.querySelectorAll('.tab_con div');
      for (var i = 0; i < lis.length; i++) {
        lis[i].setAttribute('index', i);
        lis[i].onclick = function () {
          for (var i = 0; i < lis.length; i++) {
            lis[i].className = '';
          }
          this.className = 'red';
          var index = this.getAttribute('index');
          for (var i = 0; i < div.length; i++) {
            div[i].style.display = 'none';
          }
          div[index].style.display = 'block';
        };
      }
    </script>
  </body>
</html>
